package fts.ftsdata.impl;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import fts.ftsdata.IDataFactory;
import fts.ftsdata.services.IConfigurationService;
import fts.ftsdata.services.ILookupService;
import fts.ftsdata.services.ITaggingService;
import fts.ftsdata.services.impl.ConfigurationService;
import fts.ftsdata.services.impl.LookupService;
import fts.ftsdata.services.impl.TaggingService;


public class DataFactory implements IDataFactory
{
	SessionFactory sessionFactory = null;
	LookupService lookup;
	TaggingService tagging;
	ConfigurationService configuration;
	
	public DataFactory()
	{
		sessionFactory = new Configuration().configure().buildSessionFactory();
		lookup = new LookupService(sessionFactory);
		tagging = new TaggingService(sessionFactory, lookup);
		configuration = new ConfigurationService(sessionFactory);
	}
	
	
	public synchronized ILookupService getLookupService()
	{
		System.out.println(Thread.currentThread().getStackTrace()[1]);

		return lookup;
	}

	public synchronized ITaggingService getTaggingService()
	{
		System.out.println(Thread.currentThread().getStackTrace()[1]);

		return tagging;
	}

	public IConfigurationService getConfigurationService()
	{
		System.out.println(Thread.currentThread().getStackTrace()[1]);

		return configuration;
	}

}
